package com.xpgk.mvc.productSales;

import java.util.List;

import com.jfinal.log.Log;
import com.xpgk.annotation.Table;
import com.xpgk.mvc.base.BaseModel;


/**
 * 产品销售表
 * */
@SuppressWarnings("unused")
@Table(tableName = ProductSales.table_name)
public class ProductSales extends  BaseModel<ProductSales>{
	

	private static final Log log = Log.getLog(ProductSales.class);

	public static final ProductSales dao = new ProductSales().dao();
	
	
	/**
	 * 表名称
	 */
	public static final String table_name = "sb_product_sales_detail";
	
	
	
	/**
	 * 字段描述：主键 字段类型：character varying 长度：32
	 */
	public static final String column_ids = "ids";
	/**
	 * 字段描述：销售订单id 字段类型：character varying 长度：32
	 */
	public static final String column_orderIds= "orderIds";
	/**
	 * 字段描述：机构id 字段类型：character varying 长度：32
	 */
	public static final String column_organids= "organids";
	/**
	 * 字段描述：产品类别 字段类型：character varying 长度：32
	 */
	public static final String column_type = "type";
	/**
	 * 字段描述：产品ids  字段类型：character varying 长度：32
	 */
	public static final String column_productID = "productID";
	/**
	 * 字段描述：顾客（会员）ids 字段类型：character varying 长度：32
	 */
	public static final String column_customerID = "customerID";
	/**
	 * 字段描述：产品数量 字段类型：int  长度：11
	 */
	public static final String column_number = "number";
	/**
	 * 字段描述：操作员 字段类型：character varying 长度：32
	 */
	public static final String column_userID = "userID";
	/**
	 * 字段描述：单价字段类型：float 长度：32
	 */
	public static final String column_unitPrice = "unitPrice";
	public static final String column_dataStatus = "dataStatus";
	/**
	 * 字段描述：销售价格 字段类型：float 长度：32
	 */
	public static final String column_price = "price";
	/**
	 * 字段描述：销售时间 字段类型：datetime 
	 */
	public static final String column_date = "date";
	/**
	 * 字段描述：消费类别   字段类型：character varying 长度：255
	 */
	public static final String column_consumerType = "consumerType";
	/**
	 * 字段描述：校验位 字段类型：character varying 长度：100
	 */
	public static final String column_jyw = "jyw";
	/**
	 * 字段描述：备注 字段类型：character varying 长度：255
	 */
	public static final String column_bz = "bz";
	
	/**
	 * 字段描述：该条数据添加人员is  字段类型：character varying 长度：32
	 */
	public static final String column_createId = "createId";
	/**
	 * 字段描述：该条数据添加时间  字段类型：datetime 长度：0
	 */
	public static final String column_createDate = "createDate";
	/**
	 * 字段描述：该条数据更新人员id  字段类型：character varying 长度：100
	 */
	public static final String column_updateId = "upateId";
	/**
	 * 字段描述：该条数据更新时间  字段类型：datetime 长度：0
	 */
	public static final String column_updateDate = "updateDate";
	/**
	 * sqlId : sb.productSales.selPSByCusIds 描述：根据机构ids和产品id查询库存
	 */
	public static final String sqlId_selPSByCusIds = "sb.productSales.selPSByCusIds";
	/**
	 * sqlId : sb.productSales.selByProAndDate 描述：根据产品和时间查询
	 */
	public static final String sqlId_selByProAndDate = "sb.productSales.selByProAndDate";
	
	
	/**根据订单ids和机构ids获取订单详情
	 * 
	 * @param orderIds
	 * @param orgIds
	 * @return
	 */
	public  List<ProductSales> getProductSaless(String orderIds,String orgIds)
	{	
		String sql="SELECT  sp.`name`,sys_getCodeName(sp.typeIds) type,sp.`status`,sp.proCapacity capacity,sps.number,sps.unitPrice  unitprice,sps.price total,sps.date  time"
					+" FROM sb_product_sales_detail sps  LEFT JOIN sb_product sp ON sps.productID = sp.ids  "
					+" WHERE  sps.orderIds = ?  AND  sps.organids = ? ";
		return ProductSales.dao.find(sql,orderIds,orgIds);
	}
	
}
